//
//  MeHeaderView.m
//  X-Tribe
//
//  Created by Miss.Ou on 16/3/29.
//  Copyright © 2016年 Miss.Ou. All rights reserved.
//

#import "MeHeaderView.h"

@implementation MeHeaderView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    
    return self;
}

-(void)createSubviews{
    
    self.backgroundColor = [UIColor whiteColor];

    self.avatarImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cycle_image1.jpg"]];
    self.avatarImg.backgroundColor = [UIColor blueColor];
    [self addSubview:self.avatarImg];
    [self.avatarImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(30);
        make.width.mas_equalTo(self.mas_width).multipliedBy(0.2);
        make.height.mas_equalTo(self.mas_width).multipliedBy(0.2);
        
    }];
    self.avatarImg.layer.masksToBounds = YES;
    self.avatarImg.layer.cornerRadius = self.width * 0.1;
    
    self.userName = [[UILabel alloc] init];
    self.userName.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.userName];
    [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.mas_equalTo(self.avatarImg);
        make.left.mas_equalTo(self.avatarImg.mas_right).offset(10);
        make.right.mas_equalTo(self).offset(-30);
        
    }];
    self.userName.text = @"1169337928@qq.com";
    
    self.myDream = [[UILabel alloc] init];
    self.myDream.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.myDream];
    [self.myDream mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.avatarImg);
        make.top.mas_equalTo(self.avatarImg.mas_bottom).offset(10);
        make.right.mas_equalTo(self.userName);
        make.height.mas_equalTo(30);
        
    }];
    _myDream.font = [UIFont systemFontOfSize:14];
    _myDream.textAlignment = NSTextAlignmentCenter;
    _myDream.text = @"my dream is to be someone ";
    
    self.like = [self creatLabelWithName:@"赞我的" Count:@(256)];
    [self.like mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(_myDream.mas_bottom).offset(10);
        make.left.bottom.mas_equalTo(self);
        make.width.mas_equalTo(self.mas_width).multipliedBy(0.3);
    }];
    self.comments = [self creatLabelWithName:@"评论" Count:@(1223)];
    [self.comments mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.mas_equalTo(self.like);
        make.width.mas_equalTo(self.mas_width).multipliedBy(0.4);
        make.left.mas_equalTo(self.like.mas_right);

    }];
    self.points = [self creatLabelWithName:@"章鱼币" Count:@(222)];
    [self.points mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.mas_equalTo(self.like);
        make.right.mas_equalTo(self);
        make.width.mas_equalTo(self.mas_width).multipliedBy(0.3);
        
    }];

}

//创建Label的方法
-(UILabel *)creatLabelWithName:(NSString *)name Count:(NSNumber *)count{
    
    UILabel *label = [[UILabel alloc] init];
    label.backgroundColor = [UIColor colorWithRed:1.00 green:0.79 blue:0.57 alpha:1.00];
    [self addSubview:label];
    label.numberOfLines = 2;
    label.text = [NSString stringWithFormat:@"%@ : %@",name,count];
    label.userInteractionEnabled = YES;
    label.textAlignment = NSTextAlignmentCenter;
    return label;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
